<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <div v-if="crud.props.searchToggle">
        <!-- 搜索 -->
        <el-select v-model="query.daTaskId" clearable filterable class="filter-item" placeholder="选择任务">
          <el-option
            v-for="item in task.da_task"
            :key="item.id"
            :label="item.serialnumber"
            :value="item.id">
          </el-option>
        </el-select>
        <rrOperation :crud="crud" />
      </div>
      <!--如果想在工具栏加入更多按钮，可以使用插槽方式， slot = 'left' or 'right'-->
      <crudOperation :permission="permission" />
      <!--表单组件-->
      <el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible="crud.status.cu > 0" :title="crud.status.title" width="500px">
        <el-form ref="form" :model="form" :rules="rules" size="small" label-width="85px">
          <el-form-item label="北京时间" prop="beijingTime">
            <el-date-picker v-model="form.beijingTime" type="datetime" format="yyyy-MM-dd HH:mm:ss" style="width: 260px;" /><el-input v-model="form.beijingTimeSSS" style="width: 110px;" />
          </el-form-item>
          <el-form-item label="经度" prop="longitude">
            <el-input v-model="form.longitude" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="纬度" prop="latitude">
            <el-input v-model="form.latitude" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="大地高(H)" prop="geodeticHeight">
            <el-input v-model="form.geodeticHeight" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="靶场(XB)" prop="siteX">
            <el-input v-model="form.siteX" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="靶场(YB)" prop="siteY">
            <el-input v-model="form.siteY" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="靶场(HB)" prop="siteH">
            <el-input v-model="form.siteH" style="width: 370px;" />
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button type="text" @click="crud.cancelCU">取消</el-button>
          <el-button :loading="crud.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
        </div>
      </el-dialog>
      <!--表格渲染-->
      <el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
        <el-table-column type="selection" width="55" />
        <!-- <el-table-column v-if="columns.visible('daSubtaskId')" prop="daSubtaskId" label="设备">
          <template slot-scope="scope">
            {{ dict.label.dept_status[scope.row.daSubtaskId] }}
          </template>
        </el-table-column> -->
        <el-table-column v-if="columns.visible('beijingTime')" prop="beijingTime" label="北京时间">
          <template slot-scope="scope">
            <span>{{ parseTimeS(scope.row.beijingTime) }}</span>
          </template>
        </el-table-column>
        <el-table-column v-if="columns.visible('longitude')" prop="longitude" label="经度" />
        <el-table-column v-if="columns.visible('latitude')" prop="latitude" label="纬度" />
        <el-table-column v-if="columns.visible('geodeticHeight')" prop="geodeticHeight" label="大地高(H)" />
        <el-table-column v-if="columns.visible('siteX')" prop="siteX" label="靶场(XB)" />
        <el-table-column v-if="columns.visible('siteY')" prop="siteY" label="靶场(YB)" />
        <el-table-column v-if="columns.visible('siteH')" prop="siteH" label="靶场(HB)" />
        <el-table-column v-if="columns.visible('createUser')" prop="createUser" label="创建人" />
        <el-table-column v-if="columns.visible('createDate')" prop="createDate" label="创建时间">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.createDate) }}</span>
          </template>
        </el-table-column>
        <el-table-column v-if="columns.visible('updateUser')" prop="updateUser" label="最后修改人" />
        <el-table-column v-if="columns.visible('updateDate')" prop="updateDate" label="最后修改时间">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.updateDate) }}</span>
          </template>
        </el-table-column>
        <el-table-column v-permission="['admin','daSubtaskData01:edit','daSubtaskData01:del']" label="操作" width="150px" align="center">
          <template slot-scope="scope">
            <udOperation
              :data="scope.row"
              :permission="permission"
            />
          </template>
        </el-table-column>
      </el-table>
      <!--分页组件-->
      <pagination />
    </div>
  </div>
</template>

<script>
import crudDaSubtaskData01 from '@/api/daSubtaskData01'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'

// crud交由presenter持有
const defaultCrud = CRUD({ title: '数据01', url: 'api/daSubtaskData01/other', sort: 'id,desc', crudMethod: { ...crudDaSubtaskData01 }})
const defaultForm = { id: null, daSubtaskId: null, beijingTime: null, longitude: null, latitude: null, geodeticHeight: null, siteX: null, siteY: null, siteH: null, isDelete: null, createUser: null, createDate: null, updateUser: null, updateDate: null,beijingTimeSSS: null }
export default {
  name: 'DaSubtaskData01',
  components: { pagination, crudOperation, rrOperation, udOperation },
  mixins: [presenter(defaultCrud), header(), form(defaultForm), crud()],
  tasks: [],
  dicts: ['dept_status'],mounted () {
  console.log("11",this.crud);
},
  data() {
    return {
      permission: {
        add: ['admin', 'daSubtaskData01:add'],
        edit: ['admin', 'daSubtaskData01:edit'],
        del: ['admin', 'daSubtaskData01:del']
      },
      rules: {
        daSubtaskId: [
          { required: true, message: '设备不能为空', trigger: 'blur' }
        ],
        beijingTime: [
          { required: true, message: '北京时间不能为空', trigger: 'blur' }
        ],
        longitude: [
          { required: true, message: '经度不能为空', trigger: 'blur' }
        ],
        latitude: [
          { required: true, message: '纬度不能为空', trigger: 'blur' }
        ],
        geodeticHeight: [
          { required: true, message: '大地高(H)不能为空', trigger: 'blur' }
        ],
        siteX: [
          { required: true, message: '靶场(XB)不能为空', trigger: 'blur' }
        ],
        siteY: [
          { required: true, message: '靶场(YB)不能为空', trigger: 'blur' }
        ],
        siteH: [
          { required: true, message: '靶场(HB)不能为空', trigger: 'blur' }
        ]
      },
      queryTypeOptions: [
        { key: 'daSubtaskId', display_name: '设备' }
      ]
    }
  },
  methods: {
    // 获取数据前设置好接口地址
    [CRUD.HOOK.beforeRefresh]() {
      const query = this.query
      if (query.type && query.value) {
        this.crud.params[query.type] = query.value
      }
      return true
    }
  }
}
</script>

<style scoped>

</style>
